<?php
/**
 * @copyright keke-teach
 * @author shang
 * @version v 1.2
 * 2010-9-2 10:42:00
 */
if (! defined ( 'IN_KEKE' )) {
	exit ( 'Access Denied' );
}

$shop_info = $shop_info_arr[0];

$order_obj = new Keke_witkey_service_order_class();

$where = '  1 = 1 and a.buy_uid = '.$uid;
$service_status=keke_glob_class::get_service_status();


$buy_count=db_factory::query(" select count(*) as count,b.service_type as type from ".TABLEPRE."witkey_service_order as a left join ".TABLEPRE."witkey_service as b on a.service_id= b.service_id  where a.buy_uid = '$uid' group by b.service_type");
foreach ($buy_count as $k=>$v) {
	$temp_arr[$v['type']] = $v['count'];
}
$buy_count = $temp_arr;

$page_size = intval($page_size)?intval($page_size):10;
	

$sql_str = "select  * from
					".TABLEPRE."witkey_service_order a 
					left join ".TABLEPRE."witkey_service b on a.service_id= b.service_id
					where ";
$sql_count = "select  count(*) as count from
					".TABLEPRE."witkey_service_order a
					inner join ".TABLEPRE."witkey_service b on a.service_id= b.service_id
					where ";
if($service_type)
{
	$where.=" and b.service_type= $service_type";
}
else
{
  $where.="  and b.service_type= 2";
}
$service_type=intval($service_type)?intval($service_type):2;
$where.= ' order by order_id desc';
$ct = db_factory::query($sql_count.$where);
$count = $ct[0][count];


$url ='index.php?do='.$do.'&view='.$view.'&page_size='.$page_size.'&service_type='.$service_type;
$page = $_GET ['page'] ? $_GET ['page'] : 1;
$limit=$page_size;

$pages = $page_obj->getPages($count,$limit,$page,$url);
	

$order_arr = db_factory::query($sql_str.$where.$pages[where]);

require_once keke_tpl_class::template ($do."_".$view);